package io.gitee.twoke.generator.engine.impl.cmd;

import io.gitee.twoke.generator.engine.impl.interceptor.Command;
import io.gitee.twoke.generator.engine.impl.interceptor.CommandContext;

/**
 * 模板文件是基于模板存在的，当模板删除时，模板需要级联删除
 */
public class DeleteTemplateCmd implements Command<Void> {

    private String templateId;

    public DeleteTemplateCmd(String templateId) {
        this.templateId = templateId;
    }

    @Override
    public Void execute(CommandContext commandContext) {
        commandContext.getTemplateEntityManager().delete(this.templateId);
        commandContext.getTemplateFileEntityManager().deleteTemplateFilesByTemplateId(this.templateId);

        return null;
    }
}